package com.itheima.dubbo.web;

import com.itheima.dubbo.User;
import com.itheima.dubbo.service.UserInterface;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Version: V1.0
 */
@RestController
@RequestMapping("user")
public class UserController {

//    @DubboReference(timeout = 5000) //消费方优于提供方
    @DubboReference(check = false,cluster = "failfast")
//    @DubboReference(version = "1.0.1",check = false)
    UserInterface userInterface;    //远程调用

    @GetMapping("hello")
    public String hello( String username) {
        RpcContext.getContext().setAttachment("itcast","666");
        return userInterface.hello(username);
    }

    @GetMapping("findUser")
    public User findUser(String name){
        User userVo = new User();
        userVo.setName(name);
        User user = userInterface.findUser(userVo);
        return user;
    }

}